/****************************************************************************
**
** ServerList.cpp
**
** Copyright (C) August 2014 Hotride
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
*****************************************************************************
*/
//---------------------------------------------------------------------------
#include "stdafx.h"
//---------------------------------------------------------------------------
TServerList::TServerList()
:m_Count(0), m_ID(NULL), m_Name(NULL), m_SelectedServer(0)
{
}
//---------------------------------------------------------------------------
TServerList::~TServerList()
{
	if (m_Count > 0)
	{
		delete m_ID;
		delete []m_Name;
	}
}
//---------------------------------------------------------------------------
void TServerList::SetCount(int val)
{
	if (m_Count)
	{
		delete m_ID;
		delete []m_Name;
	}
	m_Count = val;
	if (m_Count < 1)
	{
		m_Count = 0;
		m_ID = NULL;
		m_Name = NULL;
		return;
	}
	m_ID = new WORD[m_Count];
	m_Name = new string[m_Count];
	for (int i = 0; i < m_Count; i++)
	{
		m_ID[i] = 0;
		m_Name[i] = "";
	}
}
//---------------------------------------------------------------------------
void TServerList::SetName(int pos, WORD ID, string name)
{
	if (pos < 0 || pos >= m_Count) return;
	m_ID[pos] = ID;
	m_Name[pos] = name;
}
//---------------------------------------------------------------------------
WORD TServerList::GetID(int pos) const
{
	if (pos < 0 || pos >= m_Count) return 0;
	return m_ID[pos];
}
//---------------------------------------------------------------------------
string TServerList::GetName(int pos) const
{
	if (pos < 0 || pos >= m_Count) return string("");
	return m_Name[pos];
}
//--------------------------------------------------------------------------